package com.aaa.service.impl;

import com.aaa.entity.Role;
import com.aaa.mapper.RoleMapper;
import com.aaa.service.RoleService;
import com.aaa.vo.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Override
    public R findAll() {
        List<Role> roles=roleMapper.selectAll();
        return new R(200,"查询成功",roles);
    }

    @Override
    public R findAllByPage(Integer current, Integer pageSize) {
        //开启分页
        PageHelper.startPage(current,pageSize);
        List<Role> roles=roleMapper.selectAll2();
        //把查询的结果封装到pageInfo
        PageInfo<Role> pageInfo=new PageInfo<>(roles);
        return new R(200,"查询成功",pageInfo);
    }
}











